package edu.unf.cen6940.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Calendar;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllThesiss", query = "select myThesis from Thesis myThesis"),
		@NamedQuery(name = "findThesisByAbstract_", query = "select myThesis from Thesis myThesis where myThesis.abstract_ = ?1"),
		@NamedQuery(name = "findThesisByAbstract_Containing", query = "select myThesis from Thesis myThesis where myThesis.abstract_ like ?1"),
		@NamedQuery(name = "findThesisByDefenseAttempts", query = "select myThesis from Thesis myThesis where myThesis.defenseAttempts = ?1"),
		@NamedQuery(name = "findThesisByDoi", query = "select myThesis from Thesis myThesis where myThesis.doi = ?1"),
		@NamedQuery(name = "findThesisByDoiContaining", query = "select myThesis from Thesis myThesis where myThesis.doi like ?1"),
		@NamedQuery(name = "findThesisByPrimaryKey", query = "select myThesis from Thesis myThesis where myThesis.thesisId = ?1"),
		@NamedQuery(name = "findThesisByProposalAttempts", query = "select myThesis from Thesis myThesis where myThesis.proposalAttempts = ?1"),
		@NamedQuery(name = "findThesisByStartDate", query = "select myThesis from Thesis myThesis where myThesis.startDate = ?1"),
		@NamedQuery(name = "findThesisByThesisId", query = "select myThesis from Thesis myThesis where myThesis.thesisId = ?1"),
		@NamedQuery(name = "findThesisByTitle", query = "select myThesis from Thesis myThesis where myThesis.title = ?1"),
		@NamedQuery(name = "findThesisByTitleContaining", query = "select myThesis from Thesis myThesis where myThesis.title like ?1"),
		@NamedQuery(name = "getThesisCount", query = "select COUNT(myThesis) from Thesis myThesis")})

@Table(catalog = "ThesisManagement", name = "Thesis")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "rms_test/edu/unf/cen6940/domain", name = "Thesis")
public class Thesis implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "thesisID", nullable = false)
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer thesisId;
	/**
	 */

	@Column(name = "title", length = 100, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String title;
	/**
	 */

	@Column(name = "abstract", length = 1024, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String abstract_;
	/**
	 */

	@Column(name = "proposalAttempts")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer proposalAttempts;
	/**
	 */

	@Column(name = "defenseAttempts")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer defenseAttempts;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "startDate")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	@DateTimeFormat(iso=ISO.DATE)
	Calendar startDate;
	/**
	 */

	@Column(name = "DOI", length = 250)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String doi;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "studentID", referencedColumnName = "studentID", nullable = false) })
	@XmlTransient
	Student student;
	/**
	 */
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(catalog = "ThesisManagement", name = "ThesisToThesisCommittee", joinColumns = { @JoinColumn(name = "thesisID", referencedColumnName = "thesisID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "thesisCommitteeID", referencedColumnName = "thesisCommitteeID", nullable = false, updatable = false) })
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.unf.cen6940.domain.Thesiscommittee> thesiscommittees;
	/**
	 */
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(catalog = "ThesisManagement", name = "ThesisToCategory", joinColumns = { @JoinColumn(name = "thesisID", referencedColumnName = "thesisID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "categoryID", referencedColumnName = "categoryID", nullable = false, updatable = false) })
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.unf.cen6940.domain.Category> categories;
	/**
	 */
	@ManyToMany(mappedBy = "thesises", fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.unf.cen6940.domain.Thesistool> thesistools;
	/**
	 */
	@ManyToMany(mappedBy = "thesises", fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.unf.cen6940.domain.Generatedproduct> generatedproducts;
	/**
	 */
	@ManyToMany(mappedBy = "thesises", fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.unf.cen6940.domain.Thesisstatus> thesisstatuses;

	/**
	 */
	public void setThesisId(Integer thesisId) {
		this.thesisId = thesisId;
	}

	/**
	 */
	public Integer getThesisId() {
		return this.thesisId;
	}

	/**
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 */
	public String getTitle() {
		return this.title;
	}

	/**
	 */
	public void setAbstract_(String abstract_) {
		this.abstract_ = abstract_;
	}

	/**
	 */
	public String getAbstract_() {
		return this.abstract_;
	}

	/**
	 */
	public void setProposalAttempts(Integer proposalAttempts) {
		this.proposalAttempts = proposalAttempts;
	}

	/**
	 */
	public Integer getProposalAttempts() {
		return this.proposalAttempts;
	}

	/**
	 */
	public void setDefenseAttempts(Integer defenseAttempts) {
		this.defenseAttempts = defenseAttempts;
	}

	/**
	 */
	public Integer getDefenseAttempts() {
		return this.defenseAttempts;
	}

	/**
	 */
	public void setStartDate(Calendar startDate) {
		this.startDate = startDate;
	}

	/**
	 */
	public Calendar getStartDate() {
		return this.startDate;
	}

	/**
	 */
	public void setDoi(String doi) {
		this.doi = doi;
	}

	/**
	 */
	public String getDoi() {
		return this.doi;
	}

	/**
	 */
	public void setStudent(Student student) {
		this.student = student;
	}

	/**
	 */
	public Student getStudent() {
		return student;
	}

	/**
	 */
	public void setThesiscommittees(Set<Thesiscommittee> thesiscommittees) {
		this.thesiscommittees = thesiscommittees;
	}

	/**
	 */
	public Set<Thesiscommittee> getThesiscommittees() {
		if (thesiscommittees == null) {
			thesiscommittees = new java.util.LinkedHashSet<edu.unf.cen6940.domain.Thesiscommittee>();
		}
		return thesiscommittees;
	}

	/**
	 */
	public void setCategories(Set<Category> categories) {
		this.categories = categories;
	}

	/**
	 */
	public Set<Category> getCategories() {
		if (categories == null) {
			categories = new java.util.LinkedHashSet<edu.unf.cen6940.domain.Category>();
		}
		return categories;
	}

	/**
	 */
	public void setThesistools(Set<Thesistool> thesistools) {
		this.thesistools = thesistools;
	}

	/**
	 */
	public Set<Thesistool> getThesistools() {
		if (thesistools == null) {
			thesistools = new java.util.LinkedHashSet<edu.unf.cen6940.domain.Thesistool>();
		}
		return thesistools;
	}

	/**
	 */
	public void setGeneratedproducts(Set<Generatedproduct> generatedproducts) {
		this.generatedproducts = generatedproducts;
	}

	/**
	 */
	public Set<Generatedproduct> getGeneratedproducts() {
		if (generatedproducts == null) {
			generatedproducts = new java.util.LinkedHashSet<edu.unf.cen6940.domain.Generatedproduct>();
		}
		return generatedproducts;
	}

	/**
	 */
	public void setThesisstatuses(Set<Thesisstatus> thesisstatuses) {
		this.thesisstatuses = thesisstatuses;
	}

	/**
	 */
	public Set<Thesisstatus> getThesisstatuses() {
		if (thesisstatuses == null) {
			thesisstatuses = new java.util.LinkedHashSet<edu.unf.cen6940.domain.Thesisstatus>();
		}
		return thesisstatuses;
	}

	/**
	 */
	public Thesis() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Thesis that) {
		setThesisId(that.getThesisId());
		setTitle(that.getTitle());
		setAbstract_(that.getAbstract_());
		setProposalAttempts(that.getProposalAttempts());
		setDefenseAttempts(that.getDefenseAttempts());
		setStartDate(that.getStartDate());
		setDoi(that.getDoi());
		setStudent(that.getStudent());
		setThesiscommittees(new java.util.LinkedHashSet<edu.unf.cen6940.domain.Thesiscommittee>(that.getThesiscommittees()));
		setCategories(new java.util.LinkedHashSet<edu.unf.cen6940.domain.Category>(that.getCategories()));
		setThesistools(new java.util.LinkedHashSet<edu.unf.cen6940.domain.Thesistool>(that.getThesistools()));
		setGeneratedproducts(new java.util.LinkedHashSet<edu.unf.cen6940.domain.Generatedproduct>(that.getGeneratedproducts()));
		setThesisstatuses(new java.util.LinkedHashSet<edu.unf.cen6940.domain.Thesisstatus>(that.getThesisstatuses()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("thesisId=[").append(thesisId).append("] ");
		buffer.append("title=[").append(title).append("] ");
		buffer.append("abstract_=[").append(abstract_).append("] ");
		buffer.append("proposalAttempts=[").append(proposalAttempts).append("] ");
		buffer.append("defenseAttempts=[").append(defenseAttempts).append("] ");
		buffer.append("startDate=[").append(startDate).append("] ");
		buffer.append("doi=[").append(doi).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((thesisId == null) ? 0 : thesisId.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Thesis))
			return false;
		Thesis equalCheck = (Thesis) obj;
		if ((thesisId == null && equalCheck.thesisId != null) || (thesisId != null && equalCheck.thesisId == null))
			return false;
		if (thesisId != null && !thesisId.equals(equalCheck.thesisId))
			return false;
		return true;
	}
}
